home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 39 / PCGAMER39.bin / games / amber / amberhub.dxr / 00025_grabbed ripple-handlers from Win ROXY.txt < prev    next >
Encoding:
Text File  |  1996-11-08  |  4.3 KB  |  120 lines

  1. -- AMBERVISION "ripple" effects --
  2.  
  3. on grabberInit
  4.   global oGrabber, gRippleSize, gCPU, gHorsepower
  5.   
  6.   --  --Open the stageToPICT XObject
  7.   --  if objectP(oGrabber) then oGrabber(mDispose)  --Trash any old versions of screen-grabber
  8.   
  9.   --If the game has 6Meg available, use small ripple; 8Meg for large; less than 6Meg, skip it
  10.   set totalRAM = the memorySize/1024   --expressed in kilobytes
  11.   --  PUT "total RAM available to the game = "& totalRAM &" K"
  12.   
  13.   if totalRAM >= 8000 AND (gHorsepower <> #low) then
  14.     preloadCast 2428, 2451
  15.     set gRippleSize = #large
  16.   else   --not enough RAM for the big ripple
  17.     if totalRAM >= 6000 then
  18.       preloadCast 2453, 2472
  19.       set gRippleSize = #small
  20.     else   --not enough RAM for the small ripple; forget it for nowΓǪ
  21.       return #lowRAM
  22.       EXIT
  23.     end if
  24.   end if
  25.   
  26.   return #OK
  27.   
  28. end grabberInit
  29.  
  30. on ripple
  31.   --OK, this one's based on flipping a series of mask castmembers 
  32.   -- (1-bit shapes) into the active cast position to outline the distortion..
  33.   global oGrabber, gLastRipple, gRippleSize, gOriginPoint
  34.   
  35.   if the ticks < (gLastRipple + 3*60) then  EXIT
  36.   
  37.   if voidP( gRippleSize ) then               -- not objectP( oGrabber ) then
  38.     set rippleStatus = grabberInit()
  39.     PUT "rippleStatus = "& rippleStatus
  40.     if rippleStatus <> #OK then EXIT  --something's gone wrong with init..
  41.   end if
  42.   
  43.   set rippleSprite = 37
  44.   puppetSprite rippleSprite, TRUE
  45.   set the ink of sprite rippleSprite = 9
  46.   
  47.   --Use the Grabber object to "ripple" a valid region of the screen (in the main view-window)
  48.   -- This should display BEHIND the headgear..
  49.   
  50.   --if there's RAM aplenty, set grab-region and mask-cast accordingly..
  51.   -- NOTE that this could be even faster with a series of RAM-resident PICTURE objects..
  52.   if gRippleSize = #small then
  53.     set firstCastPos = 2453
  54.     set lastCastPos = 2471
  55.     set grabWidth = 96
  56.     set grabHeight = 96
  57.     set rippleTempo = 2
  58.   else
  59.     set firstCastPos = 2428
  60.     set lastCastPos = 2450
  61.     set grabWidth = 160
  62.     set grabHeight = 170
  63.     set rippleTempo = 1
  64.   end if
  65.   
  66.   --Coords are monitor/global? I may need to reckon these based on current monitor dimensions..
  67.   set clipRegion = rect( the stageLeft + 112, the stageTop + 80, the stageLeft + 534, the stageTop + 356)
  68.   --  PUT "<i>  clipRegion = "& clipRegion
  69.   --Set offsets into region (random location within valid area)
  70.   set leftOffset = random(the right of clipRegion - the left of clipRegion - (grabWidth + 2))
  71.   set leftEdge = the left of clipRegion + leftOffset
  72.   
  73.   set topOffset = random( the bottom of clipRegion - the top of clipRegion - (grabWidth - 2))
  74.   set topEdge = the top of clipRegion + topOffset
  75.   
  76.   --  PUT "<i>screen coords:  leftEdge = "& leftEdge &", topEdge = "& topEdge
  77.   -- set rippleClip = oGrabber(mGetHandle,leftEdge,topEdge,leftEdge+grabWidth,topEdge+grabHeight)
  78.   set errCode = ScreenToClipboard( leftEdge, topEdge,leftEdge+grabWidth,topEdge+grabHeight )
  79.   
  80.   --  if not pictureP( rippleClip ) then
  81.   if errCode = "OK" then
  82.     ALERT "errcode = "& errCode
  83.     EXIT
  84.   end if
  85.   
  86.   --OK, now shift the bubble in the viewing area.., adjusting for stage coords vs. monitor coords..
  87.   set leftEdge = leftEdge - the stageLeft
  88.   set topEdge = topEdge - the stageTop
  89.   --  PUT "<i>stage coords:  leftEdge = "& leftEdge &", topEdge = "& topEdge
  90.   
  91.   set the loc of sprite rippleSprite = point(leftEdge + (grabWidth/2), topEdge + (grabHeight/2))
  92.   --  PUT "<i> the loc of sprite rippleSprite = "& the loc of sprite rippleSprite
  93.   set the loc of sprite rippleSprite = the loc of sprite rippleSprite + point(1,1)
  94.   --  PUT "<i> the loc of sprite rippleSprite = "& the loc of sprite rippleSprite
  95.   --   set the picture of cast firstCastPos to rippleClip   
  96.   pasteClipboardInto member firstCastPos
  97.   set the castNum of sprite rippleSprite = firstCastPos
  98.   
  99.   set newPos = firstCastPos + 2
  100.   updateStage
  101.   
  102.   repeat while newPos <= lastCastPos
  103.     --a series of (1-bit) cast which will outline the same grabbed picture
  104.     --set the castNum of sprite rippleSprite = newFrame
  105.     --try 'move cast from#, to#' instead..
  106.     --PUT "."
  107.     wait rippleTempo
  108.     move cast (newPos - 2), newPos
  109.     set the castNum of sprite rippleSprite = newPos
  110.     set newPos = newPos + 2
  111.     updateStage
  112.   end repeat
  113.   
  114.   move cast lastCastPos, firstCastPos
  115.   set the loc of sprite rippleSprite = point(-1000,-1000) + gOriginPoint
  116.   
  117.   set gLastRipple = the ticks
  118.   
  119. end ripple
  120.